package com.thunder.soft.ui.adapter;

import android.content.Intent;
import android.view.View;

import androidx.annotation.NonNull;

import com.thunder.soft.R;
import com.thunder.soft.bean.OpenSourceBean;
import com.thunder.soft.common.base.BaseAdapter;
import com.thunder.soft.common.base.BaseViewHolder;
import com.thunder.soft.databinding.AdapterOpenSourceBinding;
import com.thunder.soft.ui.activity.SystemItemDetailActivity;

import java.util.List;

public class OpenSourceAdapter extends BaseAdapter<OpenSourceBean, AdapterOpenSourceBinding> {


    @Override
    protected void onBindHolder(AdapterOpenSourceBinding binding, @NonNull BaseViewHolder<AdapterOpenSourceBinding> holder,
                                int position, @NonNull OpenSourceBean data, List<Object> payloads) {
        super.onBindHolder(binding, holder, position, data, payloads);

        binding.tvTitle.setText(data.getAuthor());
        binding.tvContent.setText(data.getContent());

        binding.openSource.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(v.getContext(), SystemItemDetailActivity.class);
                intent.putExtra("link", getData(position).getLink());
                v.getContext().startActivity(intent);
            }
        });
    }

    @Override
    protected int layoutId(int viewType) {
        return R.layout.adapter_open_source;
    }
}
